$.extend({
	loadCom:function(isRecommend){
		if(isRecommend)com();
		let url = window.location.href.split('#');
		if(url[1] == "need") $(".title .col-10").text("融资需求");
		$.loadList(isRecommend);
		$(".column ul li").each(function(index,item){
			$(this).click(function(){
				$(".column ul li").removeClass("active_com");
				$(this).addClass("active_com");
				$.loadList(isRecommend);
			});
		});
		function com(){
			$("#header").css("background-color","#ffffff");
			$($(".title .col-1 img")[0]).attr("src","static/ssjf/img/symbol/back_arrow_b.png");
			$(".title .col-10").css("color","#000000");
			$(".title .col-10").html("推荐产品");
			$(".column ul li").css("background-color","#f86941");
			$(".column .active").addClass("active_com");
			$(".content_detail_a").css("background-color","#f86941");
		}
	},
	loadList:function(isRecommend){
		var type = $(".active_com").find(".col-12").text();
		$.ajax({
			url:'ssjf/pro/list.dat',
			type:"post",
			data:{
				productType:type,
				pageNum:1,
				pageSize:6
			},
			dataType:'json',
			success:function(result){
				if(result.res == 1){
					var vals = result.obj.results;
					var html = '';
					if(vals != null && vals.length > 0){
						for(var i=0;i<vals.length;i++){
							html += '<div class="row state_passed" value='+vals[i].id+'><div class="col-5 content_detail_a"><div class="row">';
							html += '<div class="col-12">'+vals[i].money+'万元</div><div class="col-12">'+vals[i].title+'</div></div></div>';
							html += '<div class="col-7 content_detail_b font_b"><span>公司规模：'+vals[i].size+'</span>';
							html += '<span>融资周期：'+vals[i].period+'</span><span>联系电话：'+vals[i].number+'</span></div>';
							html += '<div class="col-12 font_b">贷款截止时间：'+vals[i].deadline+'</div></div>';
						}
					}
					$(".column_content").empty();
					$(".column_content").append(html);
					$(".state_passed").click(function(){
						var val = $(this).attr("value");
						if(isRecommend){
							location.href = 'ssjf/page/product.html?prevPage=ssjf/page/recommend.html&id=' + val;
						}else location.href = 'ssjf/page/product.html?prevPage=ssjf/page/state2.html&id=' + val;
					});
				}
			}
		});
	},
	loadState:function(){
		$(".column ul li").click(function(){
			$(".column ul li").removeClass("active");
			$(this).addClass("active");
			var c = $(this).find(".col-12").text();
			$.ajax({
				url:"ssjf/pro/state.dat",
				type:"post",
				data:{
					publisher:c,
					pageSize:10
				},
				dataType:"json",
				success:function(result){
					if(result.res == 1){
						var vals = result.obj.results;
						var html = '';
						for(var i = 0; i < vals.length; i++){
							var className = "state_failed";
							var img = '<div class="state_img"><img src="static/ssjf/img/symbol/failed.png"></div>';
							if(vals[i].productState == 1){
								className = "state_passed";
								img = '<div class="state_img"><img src="static/ssjf/img/symbol/success.png"></div>';
							}
							html += '<div class="row '+className+'"><div class="col-5 content_detail_a"><div class="row">';
							html += '<div class="col-12">'+vals[i].money+'万元</div><div class="col-12">'+vals[i].title+'</div></div></div>';
							html += '<div class="col-7 content_detail_b font_b"><span>公司规模：'+vals[i].size+'</span>';
							html += '<span>融资周期：'+vals[i].period+'</span><span>联系电话：'+vals[i].number+'</span></div>';
							html += '<div class="col-12 font_b">贷款截止时间：'+vals[i].deadline+'</div>';
							html += img + '</div>';
						}
						$(".column_content").empty();
						$(".column_content").append(html);
					}
				}
			});
		});
		$(".active").click();
	}
});

